package com.jianying.day05;

import com.jianying.beans.WaterSensor;
import com.jianying.func.MySinkFunction;
import com.jianying.func.WaterSensorMapFunction;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * ClassName: Flink02_Sink_Mysql
 * Package: com.atguigu.day05
 * Description:
 *
 * @Author: tubage
 * @Create: 2024/4/3 10:03
 * @Version: 1.0
 */
public class Flink03_Sink_Mysql_Self {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        SingleOutputStreamOperator<WaterSensor> wsDS = env.socketTextStream("localhost", 8888)
                .map(new WaterSensorMapFunction());

        // TODO 自定义sinkFunction 写入MySQL
        wsDS.addSink(new MySinkFunction());
       // wsDS.sinkTo()


        env.execute();
    }
}
